package com.hzk.encrypte.config;

import com.hzk.encrypte.cache.local.LocalMetaDataCache;
import com.hzk.encrypte.cache.redis.RedisMetaDataCache;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * @Description
 * @Author hzk15
 * @Date 2022/3/29
 * @Verson 1.0
 **/
@EnableConfigurationProperties(DataEncrypteProperties.class)
public class DataEncrypteCongiuration {



    @ConditionalOnProperty(prefix = "data.encrypte", name = "cache", havingValue = "redis")
    @Bean
    public RedisMetaDataCache redisMetaDataCache(StringRedisTemplate redisTemplate) {
        return new RedisMetaDataCache(redisTemplate);
    }


    @ConditionalOnProperty(prefix = "data.encrypte", name = "cache", havingValue = "local")
    @Bean
    public LocalMetaDataCache localMetaDataCache(){
        return new LocalMetaDataCache();
    }



}
